<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>查询统计管理</title>
<meta name="decorator" content="default"/>
<script src="${ctxStatic}/common/change/change.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		initVaccName(outDateVaccineQuery.companyCode,outDateVaccineQuery.vaccineId);
		$(".vaccineCompany").change(function(){
			initCompanyName($(this).val());
		});
		
		/* reset */
		$("#btnReset").click(function(){
			$("#vaccineId").val("").select2();
			$("#batchType").val("").select2();
			$("#companyCode").val("").select2();
			$("#batchNo").val("");
			$("#storeCodeName").val("");
			$("#storeCodeId").val("");
			$("#num").val("");
			$("#cType").val("").select2();
			$("#overDay").attr("checked",false);
		});
		
		/* 初始化数据 */
		if('${outDateVaccineQuery.overDay}' == '1'){
			$("#overDay").attr("checked",true);
		}else{
			$("#overDay").attr("checked",false);
		}
		
	});
	var outDateVaccineQuery = JSON.parse('${fns:toJson(outDateVaccineQuery)}');
	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
       	return false;
       }
	function down(){
		top.$.jBox.confirm("确认要导出近效期疫苗信息数据吗？","系统提示",function(v,h,f){
			if(v=="ok"){
				$("#searchForm").attr("action","${ctx}/area/vaccinate/exportOutDateReport");
				$("#searchForm").submit();
				$("#searchForm").attr("action","${ctx}/area/vaccinate/queryRecent");
			}
		},{buttonsFocus:1});
		top.$('.jbox-body .jbox-icon').css('top','55px');
	}
</script>

<style type="text/css">
	.minWidth {
		min-width: 177px;
	}
	.text-danger{
	    color: #a94442;
	}
	.text-warning {
	  color: #8a6d3b;
	}
	.text-success {
	  color: #3c763d;
	}
	#contentTable td ,#contentTable th{
		text-align: center;
	}
	#contentTable tbody tr td{
		font-size: 13px;
	}
</style>
</head>
<body>
	<ul class="nav nav-tabs">
	    <li class="active"><a href="#">近效期疫苗情况查询</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="outDateVaccineQuery" action="${ctx}/area/vaccinate/queryRecent" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<div class="breadcrumb">
			<table class="table table-bordered">
				<tr>
					<th>地区</th>
					<td>
						<sys:treeselect2 id="storeCode" name="storeCode" value="${outDateVaccineQuery.storeCode}" labelName="storeName" labelValue="${outDateVaccineQuery.storeName}"
					      title="机构" url="/sys/office/treeData" cssClass="input-medium" layer = "true" disabled="${office.grade == '50' ? 'disabled' : 'false'}"/>
					</td>
					<th>查询范围</th>
					<td>
						<form:checkboxes path="grade" items="${fns:getDictList('sys_office_grade_3')}" values="${outDateVaccineQuery.grade}" itemLabel="label" itemValue="value"/>
					</td>
					<th>疫苗批号：</th>
					<td>
						<form:input path="batchNo" id="batchNo" class="span2 minWidth"/>
					</td>
				</tr>
				<tr>
				    <th>疫苗/注射器：</th>
					<td>
						<form:select path="batchType" id="batchType" class="span2 minWidth">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('batch_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select> 
					</td>
					<th>疫苗名称:</th>
					<td>
						<form:select path="vaccineId" id="vaccineId" class="span2 minWidth vaccineCompany" >
							<form:option value="" label="--请选择--"/>
						</form:select>
					</td>
					<th>生产企业：</th>
					<td>
						<form:select path="companyCode" id="companyCode" class="span2 minWidth changeCompany">
						    <form:option value="" label="--请选择--"/> 
						</form:select>
					</td>
				</tr>
				<tr>
				    <th>疫苗类型：</th>
					<td>
						<form:select path="cType" id="cType" class="span2 minWidth">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('bs_vaccineInfo_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select> 
					</td>
					<th>距有效期不到</th>
					<td>
						<form:input path="num" type="text" class="input-medium" value="${outDateVaccineQuery.num}"/>
						<label>天(1-120)</label>
					</td>
					<th>超期一天以上</th>
					<td>
						<label><input type="checkbox" name="overDay" id="overDay" value="1"/></label>
					</td>	
				</tr>

			</table>	
		</div>
	    <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
		<input id="btnReset" type="button" class="btn btn-primary" value="重置"/>
		<input onclick="down()" class="btn btn-primary" type="button" value="导出"/>
	</form:form>
	
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>编号</th>
				<th>地区名称</th>
				<th>单位</th>
				<th>疫苗名称</th>
				<th>疫苗属性</th>
				<th>生产企业</th>
				<th>批号</th>
				<th>规格(剂/支或粒)</th>
				<th>剂量</th>
				<th>剂型</th>
				<th>有效期</th>
				<th>距离有效期(天)</th>
				<th>实际库存</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="outDateList" begin="0" varStatus="status">
			<tr  <c:if test="${outDateList.dateNum<=30}">class="text-danger"</c:if>
			     <c:if test="${outDateList.dateNum>30 && outDateList.dateNum<=90}">class="text-warning"</c:if>
			     <c:if test="${outDateList.dateNum>90 && outDateList.dateNum<120}">class="text-success"</c:if>>
				<td>
				    ${(page.pageNo-1)*page.pageSize+status.index+1 }
				</td>
				<td>
				    ${outDateList.areaName}
				</td>
				<td>
				    ${outDateList.unitName}
				</td>
				<td>
				    ${outDateList.vaccName}
				</td>
				<td>
				    ${fns:getDictLabel(outDateList.cType, 'bs_vaccine_type', '') }
				</td>
				<td>
				    ${outDateList.companyName}
				</td>
				<td>
				    ${outDateList.batchNo}
					<c:if test="${not empty outDateList.secondBatchno}">
				        <span title="(查询批号时不需要带入亚批号)" style="color: #2fa4e7;">-${outDateList.secondBatchno}</span>
				    </c:if>
				</td>
				<td>
				    ${outDateList.spec}
				</td>
				<td>
				    ${outDateList.dose}
				</td>
				<td>
				    ${outDateList.doseType}
				</td>
				<td>
				    <fmt:formatDate value="${outDateList.outBoundDate}" pattern="yyyy-MM-dd"/>
				</td>
				<td>
				     ${outDateList.dateNum}
				</td>
				<td>
				    ${outDateList.vaccNum}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>